package cn.jiedanba.cacert.common.result;

import java.io.Serializable;

public class ResponseResult implements Serializable {

	private static final long serialVersionUID = -8157613083634272196L;

	private ResponseResult(int code, boolean success, String message) {
		this.code = code;
		this.success = success;
		this.message = message;

	}

	private ResponseResult(int code, boolean success, String message, Object data) {
		this.code = code;
		this.success = success;
		this.message = message;
		this.data = data;

	}

	private int code;

	private String message;

	private Object data;

	private boolean success;

	public static ResponseResult error() {
		return new ResponseResult(500, false, "未知异常，请联系管理员");
	}

	public static ResponseResult error(String message) {
		return new ResponseResult(500, false, message);
	}

	public static ResponseResult error(int code, String message) {
		return new ResponseResult(code, false, message);
	}

	public static ResponseResult fail(Object data) {
		return new ResponseResult(-1, false, "操作失败", data);
	}

	public static ResponseResult fail(String message) {
		return new ResponseResult(-1, false, message);
	}

	public static ResponseResult fail(int code, String message) {
		return new ResponseResult(code, false, message);
	}

	public static ResponseResult fail(int code, Object data, String message) {
		return new ResponseResult(code, false, message, data);
	}

	public static ResponseResult success(Object data) {
		return new ResponseResult(0, true, "成功", data);
	}

	public static ResponseResult success(String message) {
		return new ResponseResult(0, true, message);
	}

	public static ResponseResult success(int code, Object data, String message) {
		return new ResponseResult(code, true, message, data);
	}

	public static ResponseResult success(Object data, String message) {
		return new ResponseResult(0, true, message, data);
	}

	public static ResponseResult success() {
		return new ResponseResult(0, true, "成功");
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public Boolean isSuccess() {
		return success;
	}

}
